package com.starlink.databaseservice.mapper;

import com.starlink.databaseservice.dto.PostDto;
import com.starlink.databaseservice.model.Post;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author EDY
 */
@Mapper
public interface PostMapper {
    PostMapper INSTANCE = Mappers.getMapper(PostMapper.class);

    @Mapping(target = "title", source = "postTitle")
    @Mapping(source = "postContent", target = "content")
    @Mapping(source = "postPublishTime", target = "publishDate", dateFormat = "yyyy-MM-dd HH:mm:SS")
    @Mapping(source = "postClickCount", target = "clickCount")
    @Mapping(source = "postCommentCount", target = "commentCount")
    @Mapping(source = "postLikeCount", target = "likeCount")
    @Mapping(source = "postUserId", target = "userId")
    @Mapping(source = "simpleCode", target = "code")
    PostDto postToPostDto(Post post);
}
